﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model.Bas;
using nERP.Model._Admin;

namespace nERP.Model.Fin
{
    /// <summary>
    /// 其他收入
    /// </summary>
	[Table("OtherIncome")]
    [SoftKey(nameof(OtherIncome.OtherIncomeCode))]
    [Display(Name = "_Model.OtherIncome")]
    public class OtherIncome : BasePoco,IPersistPoco,ITenant,IWorkflow
    {
        [Display(Name = "_Model._OtherIncome._OtherIncomeCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("其他收入单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string OtherIncomeCode { get; set; }
        [Display(Name = "_Model._OtherIncome._Customer")]
        [Comment("对方单位")]
        [NotMapped]
        public Customer Customer { get; set; }
        [Display(Name = "_Model._OtherIncome._Customer")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("对方单位")]
        public string CustomerId { get; set; }
        [Display(Name = "_Model._OtherIncome._SettlementAccount")]
        [Comment("结算账户")]
        [NotMapped]
        public SettlementAccount SettlementAccount { get; set; }
        [Display(Name = "_Model._OtherIncome._SettlementAccount")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("结算账户")]
        public string SettlementAccountId { get; set; }
        [Display(Name = "_Model._OtherIncome._IncomeType")]
        [Comment("收入类别")]
        [RefDicName(Name = "其他收入类别")]
        public DicField IncomeType { get; set; }
        [Display(Name = "_Model._OtherIncome._IncomeType")]
        [Comment("收入类别")]
        public Guid? IncomeTypeId { get; set; }
        [Display(Name = "_Model._OtherIncome._TotalPrice")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [Comment("金额")]
        public decimal? TotalPrice { get; set; }
        [Display(Name = "_Model._OtherIncome._MakeUser")]
        [Comment("制单人")]
        [NotMapped]
        public FrameworkUser MakeUser { get; set; }
        [Display(Name = "_Model._OtherIncome._MakeUser")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("制单人")]
        public string MakeUserId { get; set; }
        [Display(Name = "_Model._OtherIncome._InvoicesDate")]
        [Comment("单据日期")]
        public DateTime? InvoicesDate { get; set; }
        [Display(Name = "_Model._OtherIncome._Status")]
        [Comment("单据状态")]
        public StatusTypeEnum? Status { get; set; }
        [Display(Name = "_Model._OtherIncome._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._OtherIncome._InvoicesImage")]
        [Comment("单据附件")]
        public List<OtherIncomeInvoicesImage> InvoicesImage { get; set; }
        [Display(Name = "_Model._OtherIncome._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

    }
    public class OtherIncomeInvoicesImage : TopBasePoco, ISubFile
    {
        public Guid OtherIncomeId { get; set; }
        public OtherIncome OtherIncome { get; set; }
        public Guid FileId { get; set; }
        public FileAttachment File { get; set; }
        public int Order { get; set; }
    }

}
